class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2023-08-12",
      revision: "6da2bca764bf7549be973641a06ee1e4d9189751"
  version "2023-08-12"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "44b965e6fddd963e7d55e9bf43fa0b8a863226a17e7d93400627850b37a94127"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "d0141f1c954b95ae4e82188c933b5a8256537560d304df1d101bc306134c8f53"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "ea991de05030a77618175e77194050c3e1dede8cdcfa9e9eeb93a3dbf58cb0fb"
    sha256 cellar: :any_skip_relocation, ventura:        "5e3b0e50c7e69dd0a0a6cf43ecf51453b53667296d9dbf2d0e7c3e4430a7187b"
    sha256 cellar: :any_skip_relocation, monterey:       "ea3001840117f697ca0cd3e0769c87d154aa33316129cc1ac4ca1eb5cf066ecb"
    sha256 cellar: :any_skip_relocation, big_sur:        "dda163894aa450cbb990e1da4c54c94040a063a8d9fcf256382e11d4a905a73d"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "35391278aaf71d16caf9dc00f652b34b3766580648046423a87d55a99eae7a81"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
